package com.kingtown.inventory.utils;

import android.content.Context;
import com.rscja.barcode.BarcodeDecoder;
import com.rscja.barcode.BarcodeFactory;
import com.rscja.deviceapi.entity.BarcodeEntity;

public class BarcodeUtil {
    BarcodeDecoder barcodeDecoder = BarcodeFactory.getInstance().getBarcodeDecoder();
    Context context;

    public void init(Context context) {
        this.context = context;
    }

    public void start() {
        barcodeDecoder.startScan();
    }

    public void stop() {
        barcodeDecoder.stopScan();
    }

    public void open(BarcodeDecoder.DecodeCallback callback) {
        barcodeDecoder.open(context);

            /*TODO
            BarcodeUtility.getInstance().setPrefix(this,"");
            BarcodeUtility.getInstance().setSuffix(this,"");
            BarcodeUtility.getInstance().enablePlaySuccessSound(this,true); //success Sound
            BarcodeUtility.getInstance().enableVibrate(this,true);//vibrate
            BarcodeUtility.getInstance().enableEnter(this,true);//addition enter

            BarcodeUtility.getInstance().enableContinuousScan(this,true);//Continuous scanning
            BarcodeUtility.getInstance().setContinuousScanIntervalTime(this,100);//Unit: milliseconds
            BarcodeUtility.getInstance().setContinuousScanTimeOut(this,9999);//Unit: milliseconds
            */

        barcodeDecoder.setDecodeCallback(callback);
    }

    public void close() {
        barcodeDecoder.close();
    }
}
